package com.mybatis.read;

import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.scripting.xmltags.DynamicSqlSource;

import java.util.List;

/**
 * @Description
 * @Author sunxy
 * @Create 2019-12-25 16:17
 **/
public interface UserDao {
    User selectUser(Long id);
    
    @Select("  SELECT * FROM user where id = #{id}")
    @Options(useCache = false,flushCache = Options.FlushCachePolicy.TRUE)
    User selectUserByFlushTrue(Long id);
    
    @Select("select * from user  where id =#{arg0} or name =#{arg1}")
    User selectTwoParam(Long id,String name);

    @Select("select * from user  where id =#{id} or name =#{arg1}")
    User selectTwoParamAnd(@Param("id") Long id, String name);

    @Update("update `user` set name =#{arg1} where id =#{arg0}")
    int setName(Integer id,String name);
    
    @Select("select * from user ")
    List<User> listUser();

    /**测试  DynamicSqlSource 动态mybatis 解释树 {@link DynamicSqlSource}
     * @param dto 
     * @return
     */
    List<User> getUsers(@Param("dto") User dto);

    List<User> findIds(@Param("list") List<Integer> list);
}
